package com.hbsx.why.ui.space;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hbsx.why.R;
import com.hbsx.why.adapter.LGRecycleViewAdapter;
import com.hbsx.why.adapter.LGViewHolder;
import com.hbsx.why.base.BaseActivity;
import com.hbsx.why.views.ReboundScrollView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by User on 2017/8/29.
 */

public class VenueDetailActivity extends BaseActivity {

    @BindView(R.id.venue_scrollView)
    ReboundScrollView venueScrollView;
    @BindView(R.id.tv_topTitle)
    TextView tvTopTitle;
    @BindView(R.id.venue_relayout)
    LinearLayout venueRelayout;
//    @BindView(R.id.venue_list)
//    RecyclerView venueList;
    private ArrayList<String> list = new ArrayList<>();

    @Override
    protected int getLayoutResId() {
        return R.layout.venue_main;
    }

    @Override
    protected void initView() {
        list.add("1");
        list.add("2");
        CommentAdapter commentAdapter = new CommentAdapter(list);
        tvTopTitle.setText("场馆详情");
        venueScrollView.setOnScollChangedListener(new ReboundScrollView.OnScollChangedListener() {
            @Override
            public void onScrollChanged(ReboundScrollView scrollView, int x, int y, int oldx, int oldy) {
                if (y <= 0) { // 设置标题的背景颜色
                    venueRelayout.setBackgroundColor(getBgColor(0));
                } else if (y > 0 && y <= venueRelayout.getHeight()) { // 滑动距离小于banner图的高度时，设置背景和字体颜色颜色透明度渐变
                    float scale = (float) y / venueRelayout.getHeight();
                    float alpha = (255 * scale);
                    venueRelayout.setBackgroundColor(getBgColor((int) alpha));

                } else { // 滑动到banner下面设置普通颜色
                    venueRelayout.setBackgroundColor(getBgColor(255));
                }

            }
        });

    }


    public int getBgColor(int alpha) {
        return Color.argb(alpha,
                28, 92, 164);
    }

    class CommentAdapter extends LGRecycleViewAdapter<String>{

        public CommentAdapter(List<String> dataList) {
            super(dataList);
        }

        @Override
        public int getLayoutId(int viewType) {
            return 0;
        }

        @Override
        public void convert(LGViewHolder holder, String s, int position) {

        }
    }
}
